var acontrol, aoXMLHTTP;

function GetPageContentForThread( postID, oElem, userID )
{
    g_curPostID = postID;
    var sUrl = "http://" + g_Domain + "/forums/";
    
    if( !g_DEBUG )
    {
        sUrl = "http://" + g_Domain + "/";
    }

    if( postID != null && postID != -1 )
    {
		sUrl += "GetThread.aspx?PostID=" + postID;
    }
	else if( userID != null && userID != -1 )
	{
		sUrl += "GetWatchedThread.aspx?UserID=" + userID;
	}

	if (window.XMLHttpRequest) 
	{
		aoXMLHTTP = new XMLHttpRequest();
	}
	else //IE
	{
		aoXMLHTTP = new ActiveXObject("Msxml2.XmlHttp.3.0");
	}
	acontrol = oElem;
	acontrol.innerHTML = "Loading...";
	aoXMLHTTP.onreadystatechange = _OnReadyStateChange;
	aoXMLHTTP.open( "GET", sUrl, true );
	aoXMLHTTP.send("");
}

function _OnReadyStateChange()
{     
    if( aoXMLHTTP.readyState == 4 )
    {     
        if( typeof(acontrol) == "object" )
        {
			acontrol.innerHTML = aoXMLHTTP.responseText.replace( /<form.*>/gi, "" ).replace( /<\/form>/gi, "" );
        }
        selectPost(g_curPostID);  
    }
}